package com.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.model.auto.SysDict;
import com.service.ISysDictService;
import com.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2022-09-14
 */
@RestController
@RequestMapping("/sysDict")
public class SysDictController{
    @Autowired
    private ISysDictService sysDictService;

    @GetMapping("/getDict")
    public R getDict(String dictType) {
        List<SysDict> list = sysDictService.list(new LambdaQueryWrapper<SysDict>().
                eq(dictType != null && !"".equals(dictType), SysDict::getDictType, dictType));
        return R.ok(list);
    }

    @GetMapping("/getIsLock")
    public R getIsLock() {
        List<SysDict> list = sysDictService.list(new LambdaQueryWrapper<SysDict>().
                eq(SysDict::getDictType, "GAO_KAO_QI_JIAN"));
        if(Objects.nonNull(list) && list.size()>0){
            if(list.get(0).getDictValue() == 1){
                return R.ok("请求成功", true);
            }else{
                return R.ok("请求成功", false);
            }
        }
        return R.ok("请求成功", false);
    }
}
